选中Word中全部表格和修改表格列宽 |
您所在的位置:网站首页 › word 批量修改表格 › 选中Word中全部表格和修改表格列宽 |
1.背景:当word中有很多表格需要修改时,逐个修改既费时又可能有遗漏。如果能同时选中所有表格,对所有表格同步进行修改,就能大大提高效率。 2.方法:通过Word中的宏命令,选中全部表格,并修改表格列宽。 3.选中全部表格的宏命令。 在WPS中,依次选择视图>>宏>>编辑,添加代码如下: Sub SelectAllTables() Dim tempTable As Table Application.ScreenUpdating = False '判断文档是否被保护 If ActiveDocument.ProtectionType = wdAllowOnlyFormFields Then MsgBox "文档已保护,此时不能选中多个表格!" Exit Sub End If '删除所有可编辑的区域 ActiveDocument.DeleteAllEditableRanges wdEditorEveryone '添加可编辑区域 For Each tempTable In ActiveDocument.Tables tempTable.Range.Editors.Add wdEditorEveryone Next '选中所有可编辑区域 ActiveDocument.SelectAllEditableRanges wdEditorEveryone '删除所有可编辑的区域 ActiveDocument.DeleteAllEditableRanges wdEditorEveryone Application.ScreenUpdating = True End Sub宏名为SelectAllTables,保存为docm格式,后续调用时,先打开这个文件,依次选择视图>>宏>>选中要运行的宏>>运行。 4.修改第一列列宽的代码: Sub SelectAllTables1column() Dim tempTable As Table For Each tempTable In ActiveDocument.Tables '设置第一列列宽为2.4cm tempTable.Columns(1).Width = 68 Next End Sub
|
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |